<?php
/**
 * GPC Zend Framework front controller script.
 */

/*
 * All trailing slashes are optional. Code will work or without them.
 */

/* Defining the base directorires for everything */
define('ROOT', '/Users/guice/Sites');
define('WWW_ROOT', dirname(__FILE__) );

/* Define which environment you're in, 'dev' or 'production' */
define('ENVIRONMENT', 'dev');

/*
 *  TODO: Deprecated. Moving these into config DB.
 */
define('IMG_URL',   '/tools/images');
define('CSS_URL',   '/tools/css');
define('JS_URL',    '/tools/js');
define('FLASH_URL', '/tools/flash');

/* Path to the Library included with project */
$libraryPath = ROOT . '/lib';

/*
 * Path to where your config, controller and view files are being stored.
 *  - Also known as the application directory.
 */
$zfAppPath = ROOT . '/data/zf-gpcraids';

/* Shouldn't have to change unless you've moved it. */
$zfModules     = $zfAppPath . '/modules/'; // Where each models/sub-app are
$zfModels      = $zfAppPath . '/models/';  // DB Models

/* And the magic starts */
if ( 'dev' === ENVIRONMENT ) {
   error_reporting(E_ALL);
   ini_set('display_errors', true);
} else {
   error_reporting(none);
   ini_set('display_errors', false);
}

if ( ! strpos(ini_get('include_path'), $libraryPath)) {
   set_include_path($libraryPath . PATH_SEPARATOR . get_include_path());
}

if ( ! strpos(ini_get('include_path'), $zfModels)) {
   set_include_path( $zfModels . PATH_SEPARATOR . get_include_path());
}

require_once ('Zend/Controller/Front.php');
require_once ('Gpc/Controller/Plugin.php');

define('DS', DIRECTORY_SEPARATOR);

define('CONFIG', $zfAppPath . '/config.ini');

$front = Zend_Controller_Front::getInstance();
$front->addModuleDirectory($zfModules)
      ->registerPlugin(new Gpc_Controller_Plugin());

//$front->throwExceptions(true);

try {
   $front->dispatch();
} catch ( Exception $e ) {
   print "<b>Caught Exception:</b><br />";
   print "<pre>" .  $e . "</pre>";
}
?>
